<html xmlns="http://www.w3.org/1999/xhtml">
<head>
        <meta http-equiv="Content-Type" content="text/html; charset=Unicode" />
        <title>JD Speed Poller</title>
        <style type="text/css">
        body
        {
                width:260px;
                height:290px;
                margin:4px;
                padding:0px;
        }
        </style>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
		
		
		
        function init(){

                var settingsUrl = System.Gadget.Settings.readString("settingsUrl");
				var settingsPort = System.Gadget.Settings.readString("settingsPort");
                var settingsRefresh = System.Gadget.Settings.read("settingsRefresh");
                

                if(settingsUrl)
                {
                        //$("#settingsUrl").val(settingsUrl);
						document.getElementById("settingsUrl").value = settingsUrl;
                }
				
				if(settingsPort)
                {
                        //$("#settingsPort").val(settingsPort);
						document.getElementById("settingsPort").value = settingsPort;
                }				

                if(settingsRefresh)
                {
                        //$("#settingsRefresh").val(settingsRefresh);
						document.getElementById("settingsRefresh").value = settingsRefresh;
                }

        }

        function settingsClosing(event)
        {
                if(event.closeAction == event.Action.commit)
                {
                        var settingsUrl = document.getElementById("settingsUrl").value; //$("#settingsUrl").val();
						var settingsPort = document.getElementById("settingsPort").value; //$("#settingsPort").val();
                        var settingsRefresh = document.getElementById("settingsRefresh").value; //$("#settingsRefresh").val();

                        if(settingsUrl.length > 5)
                        {
                                System.Gadget.Settings.writeString("settingsUrl", settingsUrl);
                        }
                        else
                        {
                                System.Gadget.Settings.writeString("settingsUrl", "localhost");
                        }
						if(settingsPort.length > 0)
                        {
                                System.Gadget.Settings.writeString("settingsPort", settingsPort);
                        }
                        else
                        {
                                System.Gadget.Settings.writeString("settingsPort", "1337");
                        }

                        if(settingsRefresh > 0)
                        {
                                System.Gadget.Settings.write("settingsRefresh", settingsRefresh);
                        }
                        else
                        {
                                System.Gadget.Settings.write("settingsRefresh", 3);
                        }

                }

                event.cancel = false;
        }


        System.Gadget.onSettingsClosing = settingsClosing;
		$(document).ready(function() {
			init();
		});

        </script>
</head>
<body>

<div id="gadgetContent">
<p>
        <label for="settingsUrl">IP</label><br />
        <input type="text" name="settingsUrl" id="settingsUrl" size="32" value="" />
</p>
<p>
        <label for="settingsPort">Port</label><br />
        <input type="text" name="settingsPort" id="settingsPort" size="5" value="" />
</p>
<p>
        <label for="settingsRefresh">Refreshrate (sec)</label><br />
        <input type="text" name="settingsRefresh" id="settingsRefresh" size="3" value="" />
</p>
</div>
<div onload="init()" />
</body>
</html>